package Controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.coursedao;
import Dao.eventdao;
import Dao.machinedao;
import Dao.noticedao;
import Dao.openexpdao;
import Dao.scheduledao;
import Dao.selectiondao;
import Dao.userdao;
import Entity.Course;
import Entity.Event;
import Entity.Machine;
import Entity.Notice;
import Entity.OpenExp;
import Entity.Room_ced;
import Entity.Selection;
import Entity.Self_Booked_Page;
import Entity.User;
import mapper.Coursemapper;
import mapper.Eventmapper;
import mapper.Machinemapper;
import mapper.Noticemapper;
import mapper.Openexpmapper;
import mapper.Schedulemapper;
import mapper.Selectionmapper;
import mapper.Usermapper;

public class test extends HttpServlet {

	/**
		 * Constructor of the object.
		 */
	public test() {
		super();
	}

	/**
		 * Destruction of the servlet. <br>
		 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
		 * The doGet method of the servlet. <br>
		 *
		 * This method is called when a form has its tag value method equals to get.
		 * 
		 * @param request the request send by the client to the server
		 * @param response the response send by the server to the client
		 * @throws ServletException if an error occurred
		 * @throws IOException if an error occurred
		 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		coursedao nm = new coursedao();
		userdao ud= new userdao();
	    String d = "2021-12-19";   
		java.util.Date da = null;
			try {
				da = sdf.parse(d);
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			java.sql.Date date = new java.sql.Date(da.getTime());
		Course course = new Course();
		course.setCourse_Name("项目管理");
		course.setstu_Num(40);
		course.setId("1234");
		Room_ced room_ced = new Room_ced();
		room_ced.setDate(date);
		room_ced.setIfShare(false);
		room_ced.setOrder(1);
		room_ced.setRoom_Id("1001");
		nm.CreatAll(course, room_ced);
//		nm.deleteCourse("7");
		 request.getRequestDispatcher("login.jsp").forward(request,response);

	}

	/**
		 * The doPost method of the servlet. <br>
		 *
		 * This method is called when a form has its tag value method equals to post.
		 * 
		 * @param request the request send by the client to the server
		 * @param response the response send by the server to the client
		 * @throws ServletException if an error occurred
		 * @throws IOException if an error occurred
		 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("  <BODY>");
		out.print("    This is ");
		out.print(this.getClass());
		out.println(", using the POST method");
		out.println("  </BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}

	/**
		 * Initialization of the servlet. <br>
		 *
		 * @throws ServletException if an error occurs
		 */
	public void init() throws ServletException {
		// Put your code here
	}

}
